package com.yisu.expressway.api.core.service.impl;

import com.yisu.expressway.api.core.mapper.GoodsCategoryMapper;
import com.yisu.expressway.api.core.service.IGoodsCategoryService;
import com.yisu.expressway.api.domain.request.GoodsCategoryRequest;
import com.yisu.expressway.ewf.entity.GoodsCategory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品分类逻辑实现
 * Created by zj on 2017/4/28.
 */
@Service
public class GoodsCategoryServiceImpl implements IGoodsCategoryService {
    @Resource
    private GoodsCategoryMapper categoryMapper;

    @Override
    public List<GoodsCategory> getGoodsCategoryList() {
        return categoryMapper.getGoodsCategoryList();
    }

    /**
     * 通过分类编号获取商品分类
     *
     * @param categoryCode 分类编号
     * @return
     */
    @Override
    public GoodsCategory getGoodsCategoryByCategoryCode(String categoryCode) {
        return categoryMapper.getGoodsCategoryByCategoryCode(categoryCode);
    }

    /**
     * 获取一级别分类
     *
     * @return
     */
    @Override
    public List<GoodsCategory> getFirstLevelCategoryList() {
        return categoryMapper.getFirstLevelCategoryList();
    }

    /**
     * 通过父级节点获取子集商品分类列表
     *
     * @param parentCode 父级节点
     * @return 子级分类列表
     */
    @Override
    public List<GoodsCategory> getGoodsCategoryListByParentCode(String parentCode) {
        return categoryMapper.getGoodsCategoryListByParentCode(parentCode);
    }

    /**
     * 通过分类ID，获取下级分类
     *
     * @param categoryCode 当前类目ID
     * @return 子级分类列表
     */
    @Override
    public List<GoodsCategory> getChildGoodsCategoryListByCategoryCode(String categoryCode) {
        return categoryMapper.getChildGoodsCategoryListByCategoryCode(categoryCode);
    }
}
